﻿MainMod.factory('gridInfo', [function() {
    return {
        grid2Info:function() {
            return [
                { name: 'orange', data: '1' },
                { name: 'apple', data: '2' },
                { name: 'jelly', data: '3' },
                { name: 'cake', data: '4' },
                { name: 'grapes', data: '5' },
                { name: 'cucumber', data: '6' },
                { name: 'watermellon', data: '7' },
                { name: 'honey', data: '8' },
                { name: 'carrot', data: '9' },
                { name: 'peanut', data: '10' },
                { name: 'bean', data: '11' },
                { name: 'pepper', data: '12' },
                { name: 'salt', data: '13' },
                { name: 'garlic', data: '14' },
                { name: 'vanilla', data: '15' },
                { name: 'cheese', data: '16' }
            ];
        },  // this has been wired up for get via: http://rearchivist.azurewebsites.net/Fruits/json
        grid1Info:function() {
            return [
                { name: 'rose', data: 'H' },
                { name: 'lily', data: 'G' },
                { name: 'daffodil', data: 'F' },
                { name: 'lilac', data: 'E' },
                { name: 'lavender', data: 'D' },
                { name: 'daisy', data: 'C' },
                { name: 'petunia', data: 'B' },
                { name: 'pansy', data: 'A' }

            ];
        }
    };
}]);

MainMod.service('promiseService', function($q, $timeout) {
    this.promisedItem = function(name) {
        var deferred = $q.defer();
        $timeout(function() {
            deferred.resolve(name+ " done");
        }, Math.random() * 1000);
        
        return deferred.promise;
    };
    /*
        //This is how it would be done as an http call:

         var deferred = $q.defer();
            var url = 'Some URL Here';
            $http.get(url)
                .success(function(data) {
                    deferred.resolve(data);
                })
                .error(function(data, status) {
                    deferred.reject(data, status);
                });
            return deferred.promise;
        */
});